Uses routine,Process,DispProc;
var
	d:TDispatcherProcess;
	p:TProcess;
procedure proc_i;far;
var
	d:TDispatcherProcess;
	p:TProcess;
begin
	get_current_dispatcher(d);
	d.get_current_process(p);
	while true do;

end;
procedure proc_last;far;
var
	d:TDispatcherProcess;
	p:TProcess;
begin
	get_current_dispatcher(d);
	d.get_current_process(p);
	while true do
			if isEscape then
				d.stop;
end;

var
	
	i:word;
	a:array[1..255] of body_process;
	T:TProcess;
	nProcess:	word;
	Main:		descptr;
begin
	new(Main);
	writeln(MemAvail);
	writeln('enter the a number of process');
	readln(nProcess);
	for i:=1 to nProcess - 1 do a[i]:=proc_i;
	a[nProcess]:=proc_last;
	d.init(nProcess, a, Main);
	set_current_dispatcher(d);
	d.start;
	d.done;
	writeln(MemAvail);	
end.
{var
	p1,p2:TProcess;
	main:descptr;
	b:array[1..2] of body_process;
	a:array[1..2] of body_process absolute b;
procedure proc1;
far;
begin
	writeln('proc1');
	p1.TransferByProcess(p2);
end;
procedure proc2;
far;
begin
	writeln('proc2');
	p2.TransferByDescriptor(main);
end;
begin
	new(MAin);
	b[1]:=proc1;
	b[2]:=proc2;
	p1.init(a[1], 1);
	p2.init(a[2], 2);
	Transfer(Main, p1.get_descriptor);
end.	}